package com.inforich.web.controller.expandreport;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inforich.common.annotation.Log;
import com.inforich.common.core.controller.BaseController;
import com.inforich.common.enums.BusinessType;
import com.inforich.common.utils.poi.ExcelUtil;
import com.inforich.expandreport.domain.RubbishExpandReport;
import com.inforich.expandreport.domain.RubbishExpandReportCell;
import com.inforich.expandreport.service.IRubbishExpandReportService;

/**
 * 新扩改项目统计Controller
 *
 * @author lijie
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/report/expandreport")
public class RubbishExpandReportController extends BaseController {
    @Autowired
    private IRubbishExpandReportService rubbishExpandReportService;

    /**
     * 查询新扩改项目统计列表
     */
    @PreAuthorize("@ss.hasPermi('report:expandreport:list')")
    @GetMapping("/list")
    public Page<RubbishExpandReportCell> list(Page<RubbishExpandReportCell> page,
        RubbishExpandReport rubbishExpandReport) {
        Map<String, Object> map = beanToMap(rubbishExpandReport);
        rubbishExpandReportService.pageRubbishExpandReportCell(page, map);
        return page;
    }

    /**
     * 导出新扩改项目统计列表
     */
    @PreAuthorize("@ss.hasPermi('report:expandreport:export')")
    @Log(title = "新扩改项目统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RubbishExpandReport rubbishExpandReport) {
        Map<String, Object> map = beanToMap(rubbishExpandReport);
        List<RubbishExpandReportCell> list = rubbishExpandReportService.listRubbishExpandReportCell(map);
        ExcelUtil<RubbishExpandReportCell> util = new ExcelUtil<RubbishExpandReportCell>(RubbishExpandReportCell.class);
        util.exportExcel(response, list, "新扩改项目统计");
    }
}
